package edu.ynu.se.xiecheng.achitectureclass.controller;

import edu.ynu.se.xiecheng.achitectureclass.common.controller.LogicController;
import edu.ynu.se.xiecheng.achitectureclass.dao.OrderDao;
import edu.ynu.se.xiecheng.achitectureclass.entity.Customer;
import edu.ynu.se.xiecheng.achitectureclass.entity.Order;
import edu.ynu.se.xiecheng.achitectureclass.entity.ShopItem;
import edu.ynu.se.xiecheng.achitectureclass.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Order")
public class OrderController extends LogicController<OrderService, OrderDao, Order,Long> {

    public OrderController(@Autowired OrderService service) {
        super(service);
    }
    @Autowired
    private OrderService orderService;
    @PostMapping("/cancelOrder")
    public void createOrder(Customer customer) {
        orderService.createOrder(customer);
    }
    @PostMapping("/addLineItem")
    public void addLineItem(Order order, ShopItem shopItem) {
        orderService.addLineItem(order,shopItem);
    }
    @PostMapping("/payOrder")
    public void payOrder(Long orderId){
        orderService.payOrder(orderId);
    }
}
